package leetcode;

import org.junit.Test;

/**
 * @author cino
 * justCode
 */
public class leetcode122 {

    @Test
    public void test(){
        int[] prices = {1,2,3,4,5};
        System.out.println(maxProfit(prices));
    }
    public int maxProfit(int[] prices){
        int total = 0;
        for (int i = 1;i<=prices.length-1;i++){
            if (prices[i] - prices[i - 1]>0){
                total += prices[i] - prices[i - 1];
            }
        }
        return total;
    }
}
